<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

	<link href="../css/default.css" rel="stylesheet" type="text/css" />	
	<link href="saler.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src='../js/plugin/jquery.js'></script>    
	<script type="text/javascript" src='../js/plugin/jquery-calendar.js'></script>    	
    <link type="text/css" href='../js/plugin/jquery-calendar.css' rel="stylesheet" />
	
	<script type="text/javascript">
	$(function() {		
		$("#next_devtime").calendar();
		
	});
	
	function cancel()
	{
		window.location.replace("index.php");
	}
	</script>
    

</head>


<body>

<?php 
//有意向的客户
include_once("..\\common.php");
//  防止全局变量造成安全隐患 
$admin = false; 
//  启动会话，这步必不可少 
CheckSalerLogon();
?> 

 <?php  	
	$submit_time = date("Y-m-d H:i:s");
	
	$salerid = $_SESSION["salerid"];		
	$clientid =  $_GET["clientid"];	
	$clienttype= 0;

	$clientname = "";
	$contact = "";
	$next_devtime = $submit_time;
	$fundmoney = 0.0;
	$demand = 0;
	$charact = 0;
	$devspeed = 0;
	$othersalers = "";
	$remark = "";
	$dealtime = date("Y-m-d H:i:s");
	$dealmoney = 0.0;
	$addictdev = false;
	$supposesalers = "";
	
	$product="";
	
	
	//check client id is in 
	if($clientid >=0 )
	{		
		echo "修改客户资料";
		$DB = DBConnect();
		$query = "SELECT name,contact,next_devtime,fund,demand,charact,devspeed,othersalers,remark,deal_time,deal_money, addict_dev, suppose_saler,type,product FROM client WHERE id IN (SELECT clientid FROM client_saler_rel WHERE clientid = $clientid AND salerid = $salerid AND state='active') ";
		//echo $query;
		
		$result = mysql_query($query);

		if( mysql_num_rows($result) >0)
		{
			$row = mysql_fetch_row($result);
			$clientname = $row[0];
			$contact =  $row[1];
			$next_devtime = $row[2];
			$fundmoney = $row[3];
			$demand = $row[4];
			$charact = $row[5];
			$devspeed = $row[6];	
			$othersalers = $row[7];	
			$remark = $row[8];
			
			$dealtime = $row[9];
			$dealmoney = $row[10];
			$addictdev = $row[11];
			$supposesalers = $row[12];
			$clienttype = $row[13];
			$product = $row[14];
			
			if($clienttype != 2){
				$dealtime = $submit_time;	
			}
		}
		else
		{
			die("客户不存在或你无权访问！");
		}		
	}
	else{		
		echo "添加客户资料";
	}
	
 ?>


<div class='align-center' style='width=500' >
<form id="form1" name="form1" method="post" action="editclient1.php?clientid=<?php echo $clientid; ?>">
  <table width="505"  cellspacing='1' cellpadding='1'>
  	<tr>
      <td height="29">客户类型：</td>
      <td>
      <select name="clienttype" id="clienttype" >
        <option value="0" <?php if($clienttype==0)echo "selected='selected'"; ?> >一般客户</option>
        <option value="1" <?php if($clienttype==1)echo "selected='selected'"; ?> >意向客户</option>
        <option value="2" <?php if($clienttype==2)echo "selected='selected'"; ?> >成交客户</option>
        <option value="3" <?php if($clienttype==3)echo "selected='selected'"; ?> >黑客户</option>
		<option value="4" <?php if($clienttype==4)echo "selected='selected'"; ?> >重点客户</option>
      </select></td>
    </tr>
    
    <tr>
      <td width="175" height="29">客户姓名：</td>
      <td width="314"><input name="clientname" type="text" class="inputtext"  value="<?php echo $clientname; ?>" /></td>
    </tr>
    
    <tr>
      <td height="29">联系方式：</td>
      <td><input name="contact" type="text" class="inputtext" value= "<?php echo $contact; ?>"  /></td>
    </tr>
    
    <tr>
      <td height="29">提交时间：</td>
      <td><input name="subdata"  type="text" disabled="disabled" class="inputtext" value= "<?php echo $submit_time; ?>" readonly="readonly" /></td>
    </tr>
    
    <tr>
      <td height="29">下次拜访时间：</td>
      <td><input name="next_devtime" id="next_devtime" class="inputtext" type="text" value= "<?php echo $next_devtime; ?>" /></td>
    </tr>
    
    
    
    <tr>
      <td height="29">客户资金量：</td>
      <td><input name="fundmoney" type="text" class="inputtext" value= "<?php echo $fundmoney; ?>" />
        万元</td>
    </tr>
    
    <tr>
      <td height="29">客户需求：</td>
      <td>
		<select name="selectneed"  >
      	<?php 
	  		for($index = 0;$index< ClientNeedList::getCount();$index++ )
			{
				$item = ClientNeedList::getItem($index);
				echo "<option value=$index ";
				if($index == $demand)echo "selected='selected' "; echo ">";
				echo $item;
				echo "</option>";	
			}
		?>
		</select>
	  </td>
    </tr>   
    
    <tr>
      <td height="29">客户性格：</td>
      <td>
		<select name="selectcharacter" >
        <?php 
	  		for($index = 0;$index< ClientCharaList::getCount();$index++ )
			{
				$item = ClientCharaList::getItem($index);
				echo "<option value=$index ";
				if($index == $charact)echo "selected='selected' "; echo ">";
				echo $item; 
				echo "</option>";	
			}
		?>
		</select>
	   </td>
    </tr>
    
    <tr>
      <td height="29">开发速度要求：</td>
      <td>
		<select name="selectspeed" >
		<?php 
		for($index = 0;$index< ClientDevSpdList::getCount();$index++ )
		{
			$item = ClientDevSpdList::getItem($index);
			echo "<option value=$index ";
			if($index == $devspeed)echo "selected='selected' ";
			echo ">";
			echo $item;
			echo "</option>";	
		}
		?>
		</select>
	  </td>
    </tr>
    
    <tr>   
      <td height="29">是否有别人在跟：</td>
      <td><input name="othersalers" type="text" class="inputtext" id="othersalers" value="<?php echo $othersalers; ?>" /></td>
    </tr>
    
   <tr>
      <td height="29">成交时间：</td>
      <td> <input name="dealtime"  type="text" id="dealtime" class="inputtext" value= "<?php echo $dealtime; ?> " readonly="readonly"/></td>
   </tr>
    
   <tr>
      <td height="29">成交资金：</td>
      <td><input name="dealmoney" type="text" class="inputtext" value= "<?php echo $dealmoney; ?>" />万元</td>
   </tr>
   
   <tr>
      <td height="29">是否还有开发潜力：</td>
      <td><input name="addicdev" type="checkbox" value="1" <?php if($addictdev>0) echo "checked='checked' "; ?>  /></td>
    </tr>
    
    
    <tr>
      <td height="29">推荐谁来跟：</td>
      <td><input name="supposesalers" type="text" class="inputtext" id="supposesalers" value="<?php echo $supposesalers ?>" /> </td>
    </tr> 
    
    <tr>
     <td height="29">预计开发产品：</td>
      <td>
        <input name="product" type="text" class="inputtext" id="product" value="<?php echo $product; ?>" />
      </td>
    </tr>
    
    <tr>
      <td height="29">备注：</td>
      <td> <textarea name="remark" cols="45" rows="5" class="inputtext" id="remark"><?php echo $remark;?></textarea> </td>
    </tr>
    
  </table>
  <p>
    <input type="submit" name="submit" id="submit" value="提交" />     <input type="button" onClick="cancel();" value="取消" />    
  </p>
 
</form>

</div>

</body>
</html>